﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileMonitor.Service.Prototype;
using FileUtility.Log;
using FileUtility.ExceptionExt;
namespace FileMonitor.Service.Tracking
{
    public class ErrorLogTracking : ITracking
    {
        public void StartProcess(FileMonitorBase process)
        { }

        public void StopProcess(FileMonitorBase process)
        { }

        public void InsertNewFile(FileMonitorBase process, string fileName)
        { }

        public void CompleteFile(FileMonitorBase process, string fileName)
        { }

        public void PreocessErrorFile(FileMonitorBase process, string fileName, Exception ex)
        {
            SysException sysEx = ex as SysException;
            if (sysEx != null)
            {
                switch (sysEx.ExceptionCode)
                {
                    case ExceptionCode.DBSaveException:
                        Log.getInstance().WriteToLog(ex.Message, process.BaseConfiguration.LogPath);
                        break;
                    case ExceptionCode.FileContentReadException:
                        Log.getInstance().WriteToLog(ex.Message, process.BaseConfiguration.LogPath);
                        break;
                }
            }
        }

        public string TrackingName
        {
            get
            {
                return "ErrorLogTracking";
            }
        }

        public int OrderNo
        {
            get
            {
                return 3;
            }
        }
    }
}
